package com.qq.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.qq.bean.Users;
import com.qq.service.FriendshipService;
import com.qq.service.impl.FriendshipServiceImpl;

@WebServlet("/selectFriend.do")
public class FriendshipServlet extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String account = req.getParameter("account");
		String me = req.getParameter("me");
		FriendshipServiceImpl fs = new FriendshipServiceImpl();
		List<Users> users = fs.selctByLikeAccount(account,me);
		ObjectMapper mapper = new ObjectMapper();
		String json = mapper.writeValueAsString(users);
		resp.setContentType("application/json;charset=utf-8");
		mapper.writeValue(resp.getWriter(), json);
	}
}
